package com.ruoyi.crm.modules.mq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import org.springframework.amqp.core.Queue;

/**
 * 配置
 */
@Configuration
public class CrmRabbitConfig {
    public static final String CRM_QUEUE_CONTRACT_CREATED="crm_queue_contract_created";// 队列名字
    public static final String CRM_EXCHANGE_CONTRACT="crm_exchange_contract";// 交换机名字
    public static final String CRM_ROUTING_KEY_CONTRACT_CREATED="crm.routing.key.contract.created"; // 路由key名字

    // 队列
    @Bean
    public Queue crmContractCreatedQueue(){
        return new Queue(CRM_QUEUE_CONTRACT_CREATED);
    }
    // 交换机
    @Bean
    public DirectExchange crmContractDirectExchange(){
        return new DirectExchange(CRM_EXCHANGE_CONTRACT);
    }

    // 绑定
    @Bean
    public Binding crmContractBinding(Queue crmContractCreatedQueue,DirectExchange crmContractDirectExchange){
        return BindingBuilder.bind(crmContractCreatedQueue).to(crmContractDirectExchange).with(CRM_ROUTING_KEY_CONTRACT_CREATED);
    }
}
